package com.xq.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {

    /**
     * 响应码
     */
    private Integer code;

    /**
     * 响应信息
     */
    private String msg;

    /**
     * 响应主体数据
     */
    private T data;

    public static <T> Result<T> success(T data) {
        return new Result<>(1,"操作成功",data);
    }

    public static <T> Result<T> success() {
        return new Result<>(1,"操作成功",null);
    }

    public static <T> Result<T> error(T data) {
        return new Result<>(-1,"操作失败",data);
    }

}
